API Tranlator for Liberty BASIC

by Colin McMurchie

Home

API Translator

Window Help

Communication

Slider Control

Desktop Shortcuts

Quick Visual Designer

Rules for Code

DATA and Arrays

Easy Polygon

Triangle Draw

Control a Sprite

Shell to DOS

Morse Code

Batch Files

Multicolumn Listbox

Newsletter help

Index


API TRANSLATOR - by Colin McMurchie

API translator - for automated translation of Windows constants Type Definitions and Function definitiond from VB syntax to LB syntax. It requres thw Win32api.txt file to operate. It may work with other Dll documentation in VB syntax, but this is untested.

I have corrected it as far as I can. There may still be bugs. Some will be due to me, but some will be due to irregularities in the win32api.txt file. Humans put this together after all, and they did not always stick to their own conventions. I have tested the programme out as far as I can, and it seems to be accurate against Alyce's examples in her book, although variable names are sometimes different.

Where a call in the programme references another item in the win32api, I have flagged this up as a comment. I have found no way to automatically call these references however.

I have included an opportunity to load a different file than win32api.txt, although I have not tested the programme against anything else.

The 'copy' button puts the current entry on the clipboard. However the programme clears each entry each time a new item is selected. It was suggested that the code in the edit box be allowed to accumulate, so it could be copied on bloc into a basic programme. This might be good for the experienced, but perhaps not so good for the relative novice, who might get a lot of unwanted and confuing code in their programme. My suggestion would be to make an intermediate file to paste in to, which then could be studied at liesure.

Finally, as others have said, this translator is of little value to the programmer who does not understand what the API call, or the Windows constant is doing. Please regard it as providing a first stab at correct coding for any routine, rather than a definative model.

Anyone is free to use this code in their own projects, although I would expect some acknowledgement in documentation. Be aware, though, that there is a great deal of spaghetti under the hood!

Colin McMurchie


The Challenge:

This program was written in response to a coding challenge at [http://libertybasic.conforums.com/]

The challenge is to create a program that translates API calls in Visual BASIC syntax to Liberty BASIC syntax.

Requirements:

  1. Open the win32api.txt file and read function names into one combobox or listbox, constant names into another and struct names into another.
  2. Allow the user to select a function, a constant, or a struct and display the selection in Liberty BASIC format!
  3. Allow the user to copy the selection(s) to the clipboard.

Colin's program is included in the zip archive of this issue, as is the win32api.txt file. You can tokenize the program and add it to your Liberty BASIC "Run" Menu, so that API help is always at your fingertips! Colin has done an excellent job, and this tool will be invaluable to everyone who uses API calls! Thanks, Colin!

Having an API call in Liberty BASIC format is only the first step in using the Windows API. You must know what each argument means. There is no substitute for documentation. Microsoft provides documentation for the Windows API at the MS Developer Network Library, in the Platform SDK:

[http://msdn.microsoft.com/library/default.asp]

You can also find documentation here:

[http://www.mentalis.org/index2.shtml].

API documentation in downloadable HLP format is also available from Borland, here:

[http://info.borland.com/techpubs/bcppbuilder/v5/updates/ent.html] (download B5MS.ZIP)


Home

API Translator

Window Help

Communication

Slider Control

Desktop Shortcuts

Quick Visual Designer

Rules for Code

DATA and Arrays

Easy Polygon

Triangle Draw

Control a Sprite

Shell to DOS

Morse Code

Batch Files

Multicolumn Listbox

Newsletter help

Index